package fr.enseirbmatmeca.apms.hibernate.dao;

import java.util.List;

import org.springframework.dao.DataAccessException;

import fr.enseirbmatmeca.apms.spring.model.project.Project;
import fr.enseirbmatmeca.apms.spring.model.user.User;
import fr.enseirbmatmeca.apms.spring.security.ProjectRole;

/**
 * Allows performing complex actions on persistent data 
 * @author bmeurant, coudar
 */
public interface UserDAO {

    /**
     * Check if the login exists and if the password is correct in datasource. 
     * @param login : user login
     * @param password : user password
     * @return true if the login exists and if the password is correct. 
     * Otherwise, return false. 
     * @throws DataAccessException in case of Data access errors 
     * (database unreachable, etc.)
     */
    public boolean checkLogin (String login, String password);

    public User createUser(String login, String password);
    
    public String createUser(User user);

    
    public List<User> findAll();
    
    /**
     * Return a User object from a given login.
     * @param login : user login
     * @return the corresponding user object.
     * @throws DataAccessException in case of Data access errors 
     * (database unreachable, etc.)
     */
    public User getUser(String login);
    
    public boolean saveUser(User user);
    
    public String updateUser(User user);
    
    public List<ProjectRole> getProjectRoles(User user, Project project);
}